define(function(require){
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");

	var Model = function(){
	    this.phone = '';
		this.callParent();
	};
	
	Model.prototype.sendSmsCode = function(event){
	
		var phone = this.comp("phone").val();
		if(phone && this.getParentModel().testMobile(phone)){
			$.getJSON('http://www.xjzlhy.com:81/ex_community/a/api/community/sendMessage?callback=?&mobile='+phone,
			function(data){
				if(data.errMessage == 'ok'){
					
					justep.Util.hint('验证码已发送', {type:'success'});
				}
			
			});
			var seconds = 60;
			event.source.set({'label':seconds,'disabled':true});
			var timer = setInterval(function(){
				if(--seconds > 0){
					event.source.set({label:seconds});
				}else{
					event.source.set({'label':'发送','disabled':false});
					clearInterval(timer);
				}
				
			}, 1000);
		}else{
			justep.Util.hint("手机号码格式不正确", {type:"danger"});
		}
		



	};
	

	
	Model.prototype.nextStepClick  = function(event){
	
		var phone = this.comp("phone").val();
		var checkCode = this.comp("checkCode").val();
		var me = this;
		if(phone&&checkCode){
			$.getJSON('http://www.xjzlhy.com:81/ex_community/a/api/community/sendMessage?callback=?&mobile='+phone+'&code='+checkCode,
				function(data){
					if(data.errMessage = 'succeed'){
					    me.comp("windowContainer1").getInnerModel().comp('loginName').val(phone);
					    me.comp("windowContainer3").getInnerModel().comp('loginName').val(phone);
						$('.checkCodePanel').hide();
						justep.Util.hint('验证码验证成功', {type:'success'});
						$('.registerPanel').show();
					}else{
						justep.Util.hint('验证码验证失败', {type:'danger'});
					}
				
				}
			);
			
		}else{
			justep.Util.hint('请输入验证码', {type:'danger'});
		}

	};
	

	
	

	return Model;
});